package com.wuye.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import java.io.IOException;
import org.apache.commons.logging.*;

/**
 * Created by jiawenlong on 2016/6/6.
 */
@Controller
public class WebController extends  BaseController{
	private Log log = LogFactory.getLog(this.getClass());
    @RequestMapping("/{p1}/{p2}.{ext}")
    public String p1p2(@PathVariable("p1") String p1, @PathVariable("p2") String p2, @PathVariable("ext") String ext) {
        String target= "/" + ext + "/" + p1 + "/" + p2;
	log.info("to:"+target);
	return target;
    }
    @RequestMapping("/admin/{p1}/{p2}.{ext}")
    public String adminp1p2(@PathVariable("p1") String p1, @PathVariable("p2") String p2, @PathVariable("ext") String ext) {
        String target= "/admin/" + ext + "/" + p1 + "/" + p2;
	log.info("to:"+target);
	return target;
    }
    @RequestMapping("/admin/{p1}.{ext}")
    public String adminp1(@PathVariable("p1") String p1,@PathVariable("ext") String ext) {
        String target= "/admin/" + ext + "/" + p1 ;
	log.info("to:"+target);
	return target;
    }

    @RequestMapping("/{p1}.{ext}")
    public String p1(@PathVariable("p1") String p1, @PathVariable("ext") String ext) {
        String target=  "/" + ext + "/" + p1;
	log.info("to:"+target);
	return target;
    }
    @RequestMapping({"/","/home/index.jspx"})
    public String home(Model model) throws IOException {
        String target= "/home";
	log.info("to:"+target);
	return target;
    }
    @RequestMapping("/admin/login.jspx")
    public String adminLogin(Model model) throws IOException {
        String target= "/login";
	log.info("to:"+target);
	return target;
    }
    @RequestMapping("/admin")
    public String adminIndex(Model model) throws IOException {
        String target= "redirect:/admin/index.jspa" ;
	log.info("to:"+target);
	return target;
    }
}